// mixins
.chapter-accent(@color; @pale) {
  .chapter-heading {
    color: @color;

    .icon {
      opacity: .8;
    }
  }

  .card {
    &.choosed {
      border-color: @pale;
      border-color: fade(@color, 60%);
      box-shadow: 0 1px 6px fade(@color, 30%);

      &:before {
        background-color: @color;
      }
    }
  }

  .card-heading {
    > .icon {
      color: @color;
      background-color: @pale;

      &:hover {
        cursor: pointer;
      }
    }

    &.hover {
      background-color: @pale;

      > .icon {
        background-color: @color;
        color: #fff;
      }
    }

    &:hover {
      > h5 > .name {
        color: @color;
      }
    }

    > h5 > .name:hover {
      cursor: pointer;
    }

    > .btn-toggle {
      background-color: @pale;
      color: @color;

      &:hover {
        color: @pale;
        background-color: @color;
        cursor: pointer;
      }
    }
  }

  .card-content {
    > ul {
      > li {
        &:before {
          background-color: @pale;
        }

        &:hover {
          background-color: @pale;

          &:before {
            background-color: @color;
          }

          &:after {
            border-color: @color;
          }
        }
      }
    }
  }
}

.page-accent(@color; @pale) {
  .path-zui-36 {
    &:before, &:after {
      border-color: @color;
    }

    .path-1, .path-2, .path-1:before, .path-1:after, .path-2:before {
      background-color: @color;
    }
  }

  #header{
    background-color: @color;
  }

  #pageHeader {
    background-color: @pale;

    > .wrapper > .icon {
      background-color: @color;
      color: #fff;
    }
  }

  #pageContent {
    > h3:before {
      background-color: @pale;
    }
  }
}

.transition-quickly(){
  .transition(all .1s @animation-type);
}

.slide-in-up-100 {
  position: relative;
  top: 100px;

  &.in {
    top: 0
  }
}

.slide-in-right-50 {
  position: relative;
  left: 50px;

  &.in {
    left: 0
  }
}

.grow-up-in-height {
  &.show {
    height: 0;
    overflow: hidden;

    &.in {
      height: auto;
    }
  }
}


.loader {
  .transition-normal();
  text-align: center;
  padding: 0;
  opacity: 0;
  height: 0;
  overflow: hidden;
  .scale(.5);

  > .icon {
    font-size: 42px;
    display: block;
    height: 50px;
    width: 50px;
    line-height: 50px;
    margin: 0 auto;
  }

  &.loading {
    padding: 80px 0;
    opacity: 1;
    height: auto;
    .scale(1);
  }
}

.template {
  display: none
}

.path-zui-36 {
  display: inline-block;
  background-color: #fff;
  border-radius: 18px;
  height: 36px;
  width: 36px;
  position: relative;
  overflow: hidden;

  &:before, &:after {
    content: ' ';
    display: block;
    position: absolute;
    border: 2px solid @color-primary;
    left: 11px;
    width: 14px;
    height: 4px;
  }
  &:before {
    top: 9px;
    border-bottom: none;
  }

  &:after {
    top: 23px;
    border-top: none;
  }
  .path-1, .path-2, .path-1:before, .path-1:after, .path-2:before {
    display: block;
    content: ' ';
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: @color-primary;
  }
  .path-1 {
    left: 15px;
    top: 19px;
  }
  .path-1:before, .path-2:before {
    left: -2px;
    top: 2px;
  }
  .path-1:after {
    left: 2px;
    top: -2px;
  }
  .path-2 {
    left: 21px;
    top: 13px;
  }
}

.path-btn {
  border-radius: 0;

  &:focus, &:active {
    outline: none;
    background: none;
  }

  &:before, &:after, > .path-1, > .path-1:before, > .path-1:after {
    .transition(all .3s);
    position: absolute;
    content: ' ';
    display: block;
    height: 2px;
    width: 10px;
    border: 2px solid @color-gray;
    left: 19px;
    top: 18px;
  }

  &:after {
    top: 26px;
  }

  > .path-1 {
    top: 22px;
    left: 23px;
  }

  > .path-1:before, > .path-1:after {
    left: -4px;
    top: -2px;
    width: 6px;
  }

  > .path-1:after {
    top: 2px;
  }

  &:hover {
    background-color: @color-gray-lighter;
    background-color: rgba(0, 0, 0, 0.1);

    &:before, &:after, > .path-1, > .path-1:before, > .path-1:after {
      border-color: @color-fore;
      .rotate(180deg);
    }

    &:before {
      top: 26px;
    }

    &:after {
      top: 18px;
    }

    > .path-1 {
      left: 15px;
    }

    > .path-1:before {
      top: 2px;
      left: -4px;
    }

    > .path-1:after {
      top: -2px;
      left: -4px;
    }
  }

  &.path-close-btn {
    &:before, &:after, > .path-1, > .path-1:before, > .path-1:after {
      border-top: 0;
      border-bottom: 0;
    }

    > .path-1 {
      border-right: 0;
    }
  }
}

.path-max-btn {
  &:before, &:after, > .path-1, > .path-1:before, > .path-1:after {
    height: 6px;
    width: 6px;
    left: 12px;
    top: 18px;
  }

  &:before {
    border-right: 0;
    border-bottom: 0;
  }

  &:after {
    left: 16px;
    border-left: 0;
    border-bottom: 0;
  }

  > .path-1 {
    top: 22px;
    border-right: 0;
    border-top: 0;
  }

  > .path-1:before{
    border-top: 0;
    border-left: 0;
    top: 0px;
    left: 2px;
  }

  > .path-1:after {
    width: 10px;
    height: 10px;
    left: -2px;
    top: -4px;
  }

  &:hover {
    &:before, &:after, > .path-1:before, > .path-1 {
      .rotate(0deg);
    }

    &:before {
      top: 16px;
      left: 10px;
    }

    &:after {
      top: 16px;
      left: 18px;
    }

    > .path-1 {
      top: 24px;
      left: 10px;
    }

    > .path-1:before {
      top: 0px;
      left: 6px;
    }

    > .path-1:after {
      width: 4px;
      height: 4px;
      top: -3px;
      left: 3px;
    }
  }
}

body {
  .transition(background @animation-speed-fast @animation-type);
}

#header {
  background-color: @color-primary;
  color: #fff;
  margin-bottom: 20px;
  padding-top: 80px;

  small {
    opacity: .65
  }
}

#navbar {

  &.navbar-inverse {
    background: none
  }

  padding: 20px 0;
  border-bottom: none;

  .navbar-brand {
    position: relative;
    padding-left: 58px;
  }

  .path-zui-36 {
    position: absolute;
    top: 0;
    left: 10px;
  }
}

#heading {
  text-align: center;
  position: relative;
  overflow: hidden;

  > h1 {
    font-size: 48px;
    font-weight: normal;
    margin-top: 0;
  }

  > p {
    opacity: .65;
  }
}

#download {

  > .btn-primary {
    border-color: #e5e5e5;
    border-color: rgba(255, 255, 255, .65);
    margin-bottom: 15px;
  }

  padding-top: 20px;
  text-align: center;
}

#search {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 20px;
}

#searchForm {
  position: relative;

  > .icon {
    position: absolute;
    left: 14px;
    top: 14px;
    opacity: .65;
    display: block;
    width: 16px;
    text-align: center;
    height: 16px;
    color: #fff;
  }
}
#searchInput {
  .transition-quickly();
  background: none;
  border-radius: 21px;
  padding-left: 40px;
  border: 1px solid #e5e5e5;
  border-color: rgba(255, 255, 255, .6);
  color: #fff;

  .placeholder(#e5e5e5);
  .placeholder(rgba(255, 255, 255, .5));

  &:focus {
    border-color: #fff;
    background-color: rgba(255, 255, 255, .1);

    @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(rgba(0,0,0,.275), 20%);
    .box-shadow(@shadow);
  }
}

#grid {
  > .container {
    > .row > .col {
      &.hide {
        display: block;
        width: 0;
        opacity: 0;
        padding: 0;
      }
    }

    > .row + .row {
      padding-top: 10px;
      border-top: 1px solid @color-gray-pale;
    }
  }

  .chapter {
    margin-bottom: 30px;
  }

  .chapter-heading {
    > h4 {
      margin-bottom: 15px;
    }
  }

  .card {
    background-color: #fff;
    .transition-quickly();
    display: none;
    border-radius: 0;
    margin-bottom: 10px;
    border-color: #fff;
    box-shadow: none;

    &.show {
      display: block;
    }

    &.choosed {
      border-color: #808080;

      &:before {
        .transition-quickly();
        content: '按Enter键打开';
        display: block;
        position: absolute;
        right: -100%;
        top: 0;
        padding: 3px 8px;
        color: #fff;
      }
    }

    &:hover, &.open {
      border-color: @color-gray-lighter;
    }
  }

  .card-heading {
    .transition-quickly();
    position: relative;
    padding: 8px 8px 8px 64px;

    > .btn-toggle {
      .transition-quickly();
      display: block;
      text-align: center;
      position: absolute;
      right: -64px;
      top: 0;
      border-radius: 0;
      height: 64px;
      width: 0;
      color: @color-gray;
      background-color: @color-gray-pale;

      > .icon {
        font-size: 28px;
        line-height: 64px;
      }

      &:hover, &:active, &:focus {
        text-decoration: none;
      }
    }

    > .icon {
      .transition-quickly();
      background-color: @color-gray-pale;
      background-size: contain;
      background-position: center;
      position: absolute;
      width: 36px;
      height: 36px;
      line-height: 36px;
      border-radius: 18px;
      text-align: center;
      left: 13px;
      top: 13px;
      z-index: 10;
      font-style: normal;

      &.with-img {
        .opacity(.8); 
        background-color: transparent!important;

        &:hover {
          .opacity(1); 
        }
      }
    }

    > h5 {
      .transition-quickly();
      line-height: 16px;
      font-size: 16px;
      margin: 0;
      padding: 6px 0;

      > a.name {
        color: @color-fore;
      }
    }

    > small {
      display: block;
      min-height: 18px;
      white-space: normal;
      max-height: 48px;
      position: relative;
    }

    &:hover {

      > .btn-toggle {
        right: 0;
        width: 64px;
      }
    }

    &.hover {
      background-color: @color-gray-pale;

      > .icon {
        background-color: @color-gray;
        color: #fff;
        .scale(1.25);
      }
    }
  }

  .card-content {
    height: 0;
    padding: 0 10px;
    .transition-quickly();
    overflow: visible;

    > ul {
      list-style: none;
      padding: 0;
      margin: 0;
      position: relative;

      &:before {
        opacity: 0;
        z-index: 5;
        position: absolute;
        display: block;
        content: ' ';
        left: 21px;
        top: -10px;
        bottom: 14px;
        border-left: 1px dotted @color-gray-lighter;
      }

      > li {
        .transition-quickly();
        position: relative;
        padding: 5px 0 5px 54px;

        &:before {
          .transition-quickly();
          position: absolute;
          display: block;
          content: ' ';
          width: 8px;
          height: 8px;
          border-radius: 4px;
          background-color: @color-gray-lighter;
          left: 18px;
          top: 10px;
          z-index: 12;
        }

        &:after {
          position: absolute;
          display: block;
          content: ' ';
          border-bottom: 1px dotted @color-gray-lighter;
          width: 26px;
          left: 22px;
          top: 14px;
          z-index: 11;
        }

        &:hover {
          cursor: pointer;
          color: @color-fore;
          background-color: @color-gray-pale;

          &:before {
            .scale(1.25);
          }
        }
      }
    }
  }

  .card.open {
    .card-heading {
      > .icon:after {
        content: ' ';
        display: block;
        position: absolute;
        border-left: 1px dotted @color-gray-lighter;
        height: 999px;
        left: 18px;
      }

      > small {
        max-height: none;
      }
    }

    .card-content {
      padding: 10px;
      height: auto;
      border-top: 1px dashed @color-gray-pale;
      box-shadow: inset 0 10px 64px rgba(0, 0, 0, 0.03);

      > ul {
        &:before {
          opacity: 1;
        }
      }
    }

    &.without-topics {
      .card-heading {
        > .icon:after {
          display: none;
        }
      }

      .card-content {
        padding: 0;
        height: 0;
        border-top: none;
      }
    }
  }

  .chapter[data-accent="blue"] {
    .chapter-accent(@color-blue; @color-blue-pale);
  }
  .chapter[data-accent="primary"] {
    .chapter-accent(@color-primary; @color-pale);
  }
  .chapter[data-accent="yellow"] {
    .chapter-accent(@color-yellow; @color-yellow-pale);
  }
  .chapter[data-accent="green"] {
    .chapter-accent(@color-green; @color-green-pale);
  }
  .chapter[data-accent="red"] {
    .chapter-accent(@color-red; @color-red-pale);
  }
  .chapter[data-accent="brown"] {
    .chapter-accent(@color-brown; @color-brown-pale);
  }
  .chapter[data-accent="purple"] {
    .chapter-accent(@color-purple; @color-purple-pale);
  }
}

body.input-query-focus {
  #grid .card.choosed:before {
    right: 0;
  }
}

body.query-enabled {
  #grid > .container > .row + .row {
    padding-top: 0;
    border-top: none;
  }
}

@media (min-width: 992px) {
  body.query-enabled {
    #grid {
      &[data-show-col='1'] {
        > .container > .row > .col {
          float: none;
          min-width: 780px;
          margin: 0 auto;

          &.hide {
            width: 0;
          }
        }
      }
      &[data-show-col='2'] {
        > .container > .row > .col {
          width: 50%;

          &.hide {
            width: 0;
          }
        }
      }
    }
  }
}

#pageContainer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 1035;
  top: 80px;
  .transition-fast();

  > .container {
    padding: 0;
  }
}
#page {
  position: relative;
  background-color: fade(#fff, 80%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), 0 120px 220px @color-gray-pale;

  &.with-shadow #pageHeader {
    .box-shadow(0 2px 6px 0 rgba(0,0,0,.2));
  }
}
#pageHeader {
  background-color: #fafafa;
  position: relative;
  padding: 0;
  height: 64px;
  .transition-fast();

  > .wrapper {
    max-width: 1160px;
    margin: 0 auto;
    position: relative;
    padding: 8px 20px 20px 66px;
    .transition-fast();

    > .icon {
      .transition-fast();
      // .scale(1.2);
      position: absolute;
      width: 36px;
      height: 36px;
      line-height: 36px;
      border-radius: 18px;
      text-align: center;
      left: 13px;
      top: 13px;
      z-index: 10;
      font-style: normal;
      color: @color-gray;
      background-color: @color-gray-lighter;
    }

    > h2 {
      .transition-fast();
      padding: 6px 0;
      line-height: 16px;
      font-size: 16px;
      margin: 0;

      > a.name {
        color: @color-fore;

        &:hover {
          text-decoration: none;
          color: @color-fore;
          cursor: normal;
        }
      }
    }
  }

  > .path-btn {
    position: absolute;
    right: 0;
    top: 0;
    width: 48px;
    height: 48px;
  }

  > .path-max-btn {
    right: 48px;
    width: 36px;
  }

  > .btn {
    .scale(.5);
    .opacity(0);
  }
}
#pageBody {
  padding: 20px;
  position: absolute;
  top: 110px;
  bottom: 0;
  width: 100%;
  overflow-y: auto;
}
#pageContent {
  padding-left: 60px;
  position: relative;

  &:before {
    position: absolute;
    content: ' ';
    display: block;
    border-left: 1px dotted @color-gray-lighter;
    left: 24px;
    top: -20px;
    bottom: -20px;
  }

  > h3 {
    position: relative;
    margin: 0;
    padding: 20px 0 10px;

    &:before {
      position: absolute;
      content: ' ';
      display: block;
      left: -41px;
      top: 4px;
      width: 10px;
      height: 10px;
      // border: 1px solid @color-gray-light;
      background-color: #fff;
      border-radius: 5px;
    }
  }
}

body.compact-mode {
  #header, #heading, #search {
      .transition-normal();
  }

  #header {
    z-index: 1025;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 483px;
  }

  #grid {
    margin-top: 503px;
  }

  &.compact-mode-in {
    #header {
      height: 190px;

      &.with-shadow {
        .box-shadow(0 2px 6px 0 rgba(0,0,0,.2));
      }
    }

    #heading {
      opacity: 0;
      height: 0;
    }

    #search {
      padding: 0 20px;
      z-index: 1028;
    }

    #grid {
      .transition-normal();
      margin-top: 200px;
    }
  }
}

body.page-show {
  background-color: #f1f1f1;
  overflow: hidden;

  #headContainer {
    position: fixed;
    left: 0;
    top: 80px;
    right: 0;
    z-index: 1030;
  }

  #pageContainer {
    display: block;
  }

  #page {
    overflow: hidden;
    .transition-fast();
    // transition: all 8s;
  }

  #grid {
    opacity: .5;
  }

  #search {
    position: relative;
    top: -60px;
    width: 50%;
    max-width: 300px;
    .transition(none);
  }

  #searchInput {
    border-width: 1px;
    height: 36px;
    font-size: 14px;
  }

  #searchForm {
    opacity: 0;
    .scale(.75);
  }

  #searchForm > .icon {
    top: 10px;
  }

  #pageBody {
    transition: left @animation-speed-slow @animation-type, top @animation-speed-slow @animation-type;
    top: 200px;
    left: 100px;
  }

  &.page-show-in {

    #pageBody {
      top: 110px;
      left: 0;
    }

    #searchForm {
      .transition-fast();
      opacity: 1;
      .scale(1);
    }

    #page {
      background-color: #fff;
      opacity: 1;
      left: 0!important;
      top: 0!important;
      width: 100%!important;
      max-height: none!important;
    }

    #pageHeader {
      min-height: 110px;

      > .wrapper {
        padding-top: 20px;
        padding-left: 80px;

        > h2 {
          padding: 10px 0;
          font-size: 20px;
        }

        > .icon {
          left: 26px;
          top: 30px;
        }
      }

      > .btn {
        .scale(1);
        .opacity(1);
      }
    }
  }

  &.page-show-full {
    #page {
      opacity: 0;
    }

    &.page-show-in {
       #page {
         opacity: 1;
       }
    }

    #pageContainer {
      top: 0;

       > .container {
        width: 100%;
        max-width: none;
      }
    }

    #pageContent {
      padding: 0 20px 0 80px;
      max-width: 1160px;
      margin: 0 auto;

      &:before {
        left: 44px;
      }
    }

    #pageBody {
      padding: 20px 0;

      &.with-scrollbar {
        padding-left: 11px;
      }
    }

    .path-max-btn {
      &:before, &:after, > .path-1:before, > .path-1 {
        .rotate(0deg);
      }

      &:before {
        top: 16px;
        left: 10px;
      }

      &:after {
        top: 16px;
        left: 18px;
      }

      > .path-1 {
        top: 24px;
        left: 10px;
      }

      > .path-1:before {
        top: 0px;
        left: 6px;
      }

      > .path-1:after {
        width: 4px;
        height: 4px;
        top: -3px;
        left: 3px;
      }

      &:hover {
        &:before, &:after, > .path-1, > .path-1:before, > .path-1:after {
          left: 12px;
          top: 18px;
        }

        &:after {
          left: 16px;
        }

        > .path-1 {
          top: 22px;
        }

        > .path-1:before{
          top: 0px;
          left: 2px;
        }

        > .path-1:after {
          width: 10px;
          height: 10px;
          left: -2px;
          top: -4px;
        }
      }
    }

    #searchForm {opacity: 0}
  }

  &[data-page-accent="blue"] {
    .page-accent(@color-blue; @color-blue-pale);
  }
  &[data-page-accent="primary"] {
    .page-accent(@color-primary; @color-pale);
  }
  &[data-page-accent="yellow"] {
    .page-accent(@color-yellow; @color-yellow-pale);
  }
  &[data-page-accent="green"] {
    .page-accent(@color-green; @color-green-pale);
  }
  &[data-page-accent="red"] {
    .page-accent(@color-red; @color-red-pale);
  }
  &[data-page-accent="brown"] {
    .page-accent(@color-brown; @color-brown-pale);
  }
  &[data-page-accent="purple"] {
    .page-accent(@color-purple; @color-purple-pale);
  }
}
